<style scoped>
/* .layui-form>>>.layui-form-select {
    z-index: inherit;
} */
</style>

<template>
<div class="company">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>添加海运港口信息 </legend>
    </fieldset>

    <form class="layui-form ">
        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block" style="width:250px">
                <input type="text" name="name" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">国家类型</label>
            <div class="layui-input-block" style="width:250px">
                <select name="type" id="dell" style="width:250px">
                    <option value="1">国内</option>
                    <option value="2">海外</option>
                </select>
            </div>
            <!-- <label class="layui-form-label">国家类型</label>
            <div class="layui-input-block" style="width:250px">
                <input type="text" name="type" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
            </div> -->
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">国家 </label>
            <div class="layui-input-block" style="width:250px">
                <input type="text" name="country" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="submit">立即提交</button>
                <button class="layui-btn layui-btn-primary" @click="$parent.back">返回</button>
            </div>
        </div>
    </form>
</div>
</template>

<script>
export default {
    props: ['id'],
    data() {
        return {
            guid: this.id,
            adata: {},
            standard: {},
            typeEmnu: [],
            costincomeEmnu: []
        }
    },
    mounted() {
        let that = this;
        layui.use(['form'], function () {
            var form = layui.form,
                layer = layui.layer;
            //赋予完成 重新渲染select
            form.render('select');
            //提交编辑过的数据
            form.on('submit(submit)', function (data) {
                let postData = {
                    type: '1',
                    name: data.field.name,
                    country: data.field.country
                }
                let loader = layer.load();
                $.ajax({
                    url: '/sales/Port!addOrupdate.action',
                    data: postData,
                    type: "post",
                    dataType: "json",
                    success: function (res) {
                        if (res.msg == "success") {
                            that.toast("添加成功");
                            that.$parent.switchPage('WlExtras');
                        } else {
                            that.toast("系统错误");
                        }
                    },
                    complete: function () {
                        layer.close(loader);
                    }
                });
                return false;
            });
        });

    },
    methods: {
        back: function () {
            this.$parent.switchPage(this.$parent.refView);
        }
    }
}
</script>
